<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>

    <transition name="hello2" appear>
      <h1 class="bg" v-show="isShow">你好啊！</h1>
    </transition>

    <transition-group name="hello2" appear>
      <h1 class="bg" v-show="!isShow" key='1'>你好啊！</h1>
      <h1 class="bg" v-show="isShow" key='2'>尚硅谷</h1>
    </transition-group>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
.bg {
  background-color: chocolate;
}

/* 进入时起点 */
/* .hello2-enter {
    transform: translateX(-100%);
  } */

/* 进入时终点 */
/* .hello2-enter-to {
    transform: translateX(0);
  } */

/* 进入时起点 */
/* .hello2-leave {
    transform: translateX(0);
  } */

/* 进入时终点 */
/* .hello2-leave-to {
    transform: translateX(-100%);
  } */

/* 进入时起点、进入时终点 */
.hello2-enter,
.hello2-leave-to {
  transform: translateX(-100%);
}

.hello2-enter-active,
.hello2-leave-active {
  transition: 0.5s linear;
}

/* 进入时终点、进入时起点 */
.hello2-enter-to,
.hello2-leave {
  transform: translateX(0);
}
</style>